package cn.com.generaldata.os.ws.impl;

import javax.jws.WebService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import cn.com.generaldata.os.result.ReportStatWSResult;
import cn.com.generaldata.os.result.WSResult;
import cn.com.generaldata.os.service.common.ReportStatService;
import cn.com.generaldata.os.vo.ReportStatVO;
import cn.com.generaldata.os.ws.intf.ReportStatWSInterface;

/**
 * 制度报表查询Webservice.
 */
@WebService(endpointInterface = "cn.com.generaldata.os.ws.intf.ReportStatWSInterface")
public class ReportStatWS implements ReportStatWSInterface {

	private static final Logger logger = LoggerFactory.getLogger(ReportStatWS.class);

	@Autowired
	private ReportStatService reportStatService;

	@Override
	public ReportStatWSResult reportStat(ReportStatVO queryVO) {
		ReportStatWSResult result = new ReportStatWSResult();
		try {
			result.setResult(reportStatService.stat(queryVO));
		} catch (Exception e) {
			result = handleGeneralError(result, e);
		}
		return result;
	}

	private <T extends WSResult> T handleGeneralError(T result, Exception e) {
		logger.error(e.getMessage(), e);
		result.setDefaultError();
		return result;
	}

}
